package com.pai4j.zwiki.repository;

import com.pai4j.zwiki.domain.entity.ProjectAnalysisEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

/**
 * 项目分析数据访问层
 *
 * @author pai4j
 * @since 2025-10-12
 */
@Repository
public interface ProjectAnalysisRepository extends JpaRepository<ProjectAnalysisEntity, Long> {

    /**
     * 通过任务ID查找
     */
    Optional<ProjectAnalysisEntity> findByTaskId(String taskId);

    /**
     * 通过用户ID查找所有分析任务
     */
    List<ProjectAnalysisEntity> findByUserIdOrderByCreatedAtDesc(Long userId);

    /**
     * 通过状态查找
     */
    List<ProjectAnalysisEntity> findByStatus(String status);

    /**
     * 通过用户ID和状态查找
     */
    List<ProjectAnalysisEntity> findByUserIdAndStatus(Long userId, String status);
}

